defaultTasks 'clean', 'compileJava', 'test'

subprojects { proj ->

    apply plugin: 'java-library'
    apply plugin: 'maven-publish'
    apply plugin: 'signing'

    description = 'Structurizr'
    group = 'com.structurizr'
    version = '2.0.0'

    repositories {
        mavenCentral()
    }

    test {
        useJUnitPlatform()
    }

    compileJava.options.encoding = 'UTF-8'
    compileTestJava.options.encoding = 'UTF-8'

    sourceCompatibility = 17
    targetCompatibility = 17

    java {
        withJavadocJar()
        withSourcesJar()
    }

    jar {
        manifest {
            attributes(
                "Implementation-Title": "Structurizr for Java",
                "Implementation-Version": version
            )
        }
    }

    publishing {
        repositories {
            maven {
                name = "ossrh"
                url = "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
                credentials {
                    username = findProperty('ossrhUsername')
                    password = findProperty('ossrhPassword')
                }
            }
        }

        publications {
            mavenJava(MavenPublication) {
                from components.java

                pom {
                    name = 'Structurizr for Java'
                    description = 'Structurizr for Java'
                    url = 'https://github.com/structurizr/java'

                    scm {
                        connection = 'scm:git:git://github.com/structurizr/java.git'
                        developerConnection = 'scm:git:git@github.com:structurizr/java.git'
                        url = 'https://github.com/structurizr/java'
                    }

                    licenses {
                        license {
                            name = 'The Apache License, Version 2.0'
                            url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
                        }
                    }

                    developers {
                        developer {
                            id = "simon"
                            name = "Simon Brown"
                            email = "simon@structurizr.com"
                        }
                    }
                }
            }
        }
    }

    signing {
        sign publishing.publications.mavenJava
    }

}